{extend name="homeheader:header"/}
{block name="content"}
	<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_746537_hvtgl3wk5tu.css"/>
	<link rel="stylesheet" type="text/css" href="/home/css/receiving.css" />
	<body style="overflow-x: hidden;">
		<div class="receiving">
			<div class="top">
			<a href="javascript:history.back(-1)" class="back">
				<i class="iconfont">&#xe615;</i></a>
						收货地址管理
			</div>
			<div class="input shouhuobj container">
				<form action="">
					{foreach name="list" item="vo"}
						<div class="row lis">
							<div class="col-xs-6">{$vo.a_name}</div>
							<div class="col-xs-6 text-right">{$vo.a_tel}</div>
							<div class="col-xs-12 dj">{$vo.a_address}</div>
							<div class="col-xs-6 mr">
							<!--<span>&radic;</span>-->
								<div>
			     					<input type="radio" name="a_address"  title="默认地址" class="editstatus" id="{$vo.id}" {$vo.a_status===1 ?'checked':''} />
			     					<span>默认地址</span>
			 					</div>
							</div>
							<div class="col-xs-6 zs">
								<div class="row">
									<div class="col-xs-6">
										<a href="{:url('/home/user/editAddress',array('id'=>$vo['id']))}"><i class="iconfont icon-bianji1"></i>编辑</a>
									</div>
									<div class="col-xs-6">
										<a class="deleteaddress" id="{$vo.id}"><i class="iconfont icon-lajitong1 del" id="1"></i>删除</a>
									</div>
								
								</div>
							</div>
						</div>
					{/foreach}
				</form>
			</div>
			<div class="addsh">
				<a href="{:url('/home/user/addAddress')}">添加收货地址</a>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		var h=$(".chk span:nth-child(2)").height();
		var s=$(".chk span:nth-child(1)")
		s.width(h);
		s.height(s.width());
		s.css("line-height",h+"px")
		//Demo
		layui.use('form', function(){
		  var form = layui.form;
		  
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    layer.msg(JSON.stringify(data.field));
		    return false;
		  });
		});
	</script>
	<script type="text/javascript">
		$('.deleteaddress').click(function(){
			var id = $(this).attr('id');
			$.post('/home/user/deleteAddress',{id:id},function(res){
				if(res.code===1){
					layer.msg(res.msg,{icon:5});
					return false;
				}else if(res.code===0){
					layer.msg(res.msg,{icon:6});
					setTimeout(function(){
                        window.location.href="/home/user/address";
                    },1000);
				}else if(res.code===2){
					layer.msg('服务器出错',{icon:5});
					return false;
				}
			},'json');
		});
		$('.editstatus').click(function(){
			var id = $(this).attr('id');
			$.post('/home/user/editDaddress',{id:id},function(res){
				setTimeout(function(){
                    window.location.href="/home/user/address";
                },1000);
			},'json');
		});
	</script>
</html>
{/block}